package hk.linkcredit.walletservice.wallet.service.strategy;

import hk.linkcredit.walletservice.constant.Status;
import hk.linkcredit.walletservice.exception.BizException;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: jamnsin
 * @Date: 2022/6/14 19:01
 */
@Component
public class OrderStatusStrategyFactory {
    @Resource
    private Map<String, OrderStatusStrategy> orderStatusStrategyMap;

    public OrderStatusStrategy getOrderStatusStrategy(String type) {
        OrderStatusStrategy orderStatusStrategy = orderStatusStrategyMap.get(type);
        if (orderStatusStrategy == null) {
            throw new BizException(Status.SYSTEM_EXCEPTION);
        }
        return orderStatusStrategyMap.get(type);
    }
}
